package com.zyzy.leftfourdead.adapter.groupBuyAdapter;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.zyzy.leftfourdead.R;
import com.zyzy.leftfourdead.bean.PreferenceBean;
import com.zyzy.leftfourdead.bean.PrizeBean;
import com.zyzy.leftfourdead.helper.RecyclerViewAdapterHelper;

import java.util.List;

/**
 * Created by loverforever on 2016/8/24.
 */
public class PrizeRecyclerViewPagerFragmentAdapter extends RecyclerViewAdapterHelper<PrizeBean.ProductsBean> {


    public PrizeRecyclerViewPagerFragmentAdapter(Context context, List<PrizeBean.ProductsBean> list) {
        super(context, list);
    }

    @Override
    public RecyclerView.ViewHolder onCreateMyViewHolder(ViewGroup parent, int viewType) {
        View view=inflater.inflate(R.layout.item_fragment_groupbuy_recyclerview,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindMyViewHolder(RecyclerView.ViewHolder holder, int position) {
        ((ViewHolder)holder).simpleDraweeView_item_groupBuy_recyclerView.setImageURI(Uri.parse(""+list.get(position).getImages().getList()));
        ((ViewHolder)holder).textView_item_groupBuy_recyclerView_name.setText(list.get(position).getName());
        ((ViewHolder)holder).textView_item_groupBuy_subTitle.setText(list.get(position).getSubtitle());
        ((ViewHolder)holder).textView_item_groupBuy_unit.setText(list.get(position).getUnit());
        ((ViewHolder)holder).textView_item_groupBuy_vip_price.setText(""+list.get(position).getVip_price());
        ((ViewHolder)holder).textView_item_groupBuy_ordering.setText("团购价¥"+list.get(position).getOrdering());
        ((ViewHolder)holder).button_item_groupBuy_recyclerView.setOnClickListener(new View.OnClickListener() {
            @Override
            //没写完点击跳转事件
            public void onClick(View v) {
                Intent intent=new Intent();


            }
        });

    }
    class ViewHolder extends RecyclerView.ViewHolder {
        //左侧的图片  images
        private SimpleDraweeView simpleDraweeView_item_groupBuy_recyclerView;
        //500元储值卡   name
        private TextView textView_item_groupBuy_recyclerView_name;
        //我就是出来卖  生鲜食材的   subtitle
        private TextView textView_item_groupBuy_subTitle;
        //几张  几枚  几听 等等  unit
        private TextView textView_item_groupBuy_unit;
        //vip_price  ¥500.0
        private TextView textView_item_groupBuy_vip_price;
        //团购价 ¥400 ordering
        private TextView textView_item_groupBuy_ordering;
        //2人团|马上抢    按钮上的 几人团   group_limit  数据
        private Button button_item_groupBuy_recyclerView;

        public ViewHolder(View itemView) {
            super(itemView);
            simpleDraweeView_item_groupBuy_recyclerView= (SimpleDraweeView) itemView.findViewById(R.id.SimpleDraweeView_item_groupBuy_recyclerView);
            textView_item_groupBuy_recyclerView_name= (TextView) itemView.findViewById(R.id.textView_item_groupBuy_recyclerView_name);
            textView_item_groupBuy_subTitle= (TextView) itemView.findViewById(R.id.textView_item_groupBuy_subTitle);
            textView_item_groupBuy_unit= (TextView) itemView.findViewById(R.id.textView_item_groupBuy_unit);
            textView_item_groupBuy_vip_price= (TextView) itemView.findViewById(R.id.textView_item_groupBuy_vip_price);
            textView_item_groupBuy_ordering= (TextView) itemView.findViewById(R.id.textView_item_groupBuy_ordering);
            button_item_groupBuy_recyclerView= (Button) itemView.findViewById(R.id.button_item_groupBuy_recyclerView);
        }
    }
    //刷新数据
    public void reloadRecyclerView(List<PrizeBean.ProductsBean> _list, boolean isClear) {
        if (isClear) {
            list.clear();
        }
        list.addAll(_list);
        //刷新
        notifyDataSetChanged();
    }
}
